package coroutines.launch

import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.text.SimpleDateFormat
import java.util.*


class CoroutineLaunchTest {
}

fun main() {
    runBlocking {
        launch {
            val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") //设置日期格式

            println("${df.format(Date())} launch start")

            val result0 = multi(4)
            val result1 = multi(5)

            println("${df.format(Date())} launch end result0 = $result0, result1 = $result1")
        }
    }
}

suspend fun multi(num: Int): Int {
    delay(num * 1000L)

    return num * num
}